/*
 * @Author: zhangchaosen
 * @Date: 2024-06-18 13:27:39
 * @LastEditors: zhangchaosen
 * @LastEditTime: 2024-06-18 13:44:14
 * @Description: KeepAlive
 */
import { defineStore } from 'pinia'
import { KeepAliveState } from '@/store/interface'

export const useKeepAliveStore = defineStore({
  id: 'geek-keepAlive',
  state: (): KeepAliveState => ({
    keepAliveName: []
  }),
  actions: {
    // Add KeepAliveName
    addKeepAliveName(name: string) {
      !this.keepAliveName.includes(name) && this.keepAliveName.push(name)
    },
    // Remove KeepAliveName
    removeKeepAliveName(name: string) {
      this.keepAliveName = this.keepAliveName.filter(item => item !== name)
    },
    // Set KeepAliveName
    setKeepAliveName(keepAliveName: string[] = []) {
      this.keepAliveName = keepAliveName
    }
  }
})
